;Make a DM, with31 actuators. Numbering starts from top left.

function make_dm31_g, posns, psize, m_pix

p = posns
edge = 0.5*(p[7:18] + shift(p[7:18],-1))
sep =0.2/m_pix
dm = fltarr(psize,psize)
act = exp(-(shift(dist(psize),psize/2,psize/2)/sep*1.7)^2)
dm += shift(act,0,0)*p[0]
angles =( 60*findgen(6))*!pi/180.
for i=0,5 do dm += shift(act,sep*cos(angles[i]), sep*sin(angles[i]))*p[i+1]
angles =( 30*findgen(12))*!pi/180.
for i=0,11 do dm += shift(act,2*sep*cos(angles[i]), 2*sep*sin(angles[i]))*p[i+7]
angles += 15*!pi/180.
act = exp(-(shift(dist(psize),psize/2,psize/2)/sep*1.1)^2)
for i=0,11 do dm += shift(act,sep*3.3*cos(angles[i]), sep*3.5*sin(angles[i]))*edge[i]

return, dm
end
